package com.lin.game.service;

import com.lin.game.entity.User;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class UserSeviceImpl  implements IUserService{
private List<User> userList=new ArrayList<>();
    @Override
    public int register(User user) {
        for(User user1:userList){
            if(user1.getUsername().equals(user.getUsername())){
                return -1;
            }
            if(user1.getEmail().equals(user.getEmail())){
                return -2;
            }
        }
        userList.add(user);
        return 1;
    }

    @Override
    public User login(String username, String password) {
        for (User user : userList){
            if (user.getUsername().equals(username) && user.getPassword().equals(password)){
                return user;
            }
        }
        return null;
    }

    @Override
    public int sendEmailByUserName(String username) {
        return 0;
    }

    @Override
    public int updatePassword(String username, String newPassword) {
        return 0;
    }

    @Override
    public int updateHeader(String username, String header) {
        return 0;
    }
}


